package reggie.ruiji.mapper;

import org.apache.ibatis.annotations.*;
import reggie.ruiji.pojo.Category;
import reggie.ruiji.pojo.Employee;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Insert("insert into category (type,name,sort,create_time,update_time,create_user,update_user) " +
            "values (#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})"
    )
    public void save(Category category);

    @Results({
            @Result(column = "update_time", property = "updateTime")
    })
    @Select("select * from category")
    public List<Category> list();

    @Delete("delete from category where id=#{id}")
    public void delete(Long id);

    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    public void updatebyid(Category category);

    @Results({
            @Result(column = "update_time", property = "updateTime")
    })
    @Select("select * from category where type=#{type}")
    public List<Category> listByType(Integer type);


    @Select("select name from category where id=#{id}")
    public String getNameById(Long id);



}
